package com.letv.core.bean;

import android.util.Log;

import java.util.ArrayList;



public class HomeBlock implements LetvBaseBean {

	private static final long serialVersionUID = 1L;

	/**
	 * 区块名称
	 * */
	private String blockname;
	
	/**
	 * 频道Id
	 */
	private String cid;

    /**
     * 推荐后台区域编号(上报需要)
     */
    private String area;

    /**
     * 后台测试桶编号(上报需要)
     */
    private String bucket;

    /**
     * 该板块运营数据的条数(上报需要)
     */
    private String cms_num;

    /**
     * 该板块本次推荐的全局唯一标识(上报需要)
     */
    private String reid;

    /**
     * 跳转条件
     */
    private RedirectData redirectData;

    /**
     * list模板类型
     */
    private String contentStyle;

	/**
	 * 影片列表
	 * */
	private ArrayList<HomeMetaData> list;
	
	/**
	 * 是否进行了曝光统计
	 * */
	private boolean isStatForbu = false;
	
	/**
	 * 碎片id
	 */
	private String fragId;
	/**是否已经曝光了该区块的数据，统计暂时用**/
	private boolean mHasStatistics = false;
	
	public class HomeChildItemData{
		public HomeMetaData childItemData[] = new HomeMetaData[HORIZONTAL_COUNT];
		public int index;
	}
	
	public ArrayList<HomeChildItemData> arrayHomeChildItem;
	
	private static final int HORIZONTAL_COUNT = 2;
	
	public void toHomeChildItemData(){
		if (list != null && list.size() > 0){
			arrayHomeChildItem = new ArrayList<HomeBlock.HomeChildItemData>();
			int count = list.size() % HORIZONTAL_COUNT == 0 ? list.size() : list.size() + 1;
			int i = 0;
			while (i < count){
				HomeChildItemData homeChildItemData = new HomeChildItemData();
				if (list.size() > i){
					homeChildItemData.childItemData[0] = list.get(i);
					homeChildItemData.childItemData[0].index = i;
					Log.v("toHomeChildItemData", ">>childItemData1 : " + homeChildItemData.childItemData[0]);
				}
				if (list.size() > i+1){
					homeChildItemData.childItemData[1] = list.get(i+1);
					homeChildItemData.childItemData[1].index = i + 1;
					Log.v("toHomeChildItemData", ">>childItemData222 : " + homeChildItemData.childItemData[1]);
				}
				i = i + HORIZONTAL_COUNT;
				if (homeChildItemData.childItemData[1] != null || homeChildItemData.childItemData[0] != null){
					arrayHomeChildItem.add(homeChildItemData);
				}
			}
		}
		
	}
	
	public String getFragId() {
		return fragId;
	}

	public void setFragId(String fragId) {
		this.fragId = fragId;
	}
	
	public boolean isStatForbu() {
		return isStatForbu;
	}

	public void setStatForbu(boolean isStatForbu) {
		this.isStatForbu = isStatForbu;
	}

	public String getBlockname() {
		return blockname;
	}

	public void setBlockname(String blockname) {
		this.blockname = blockname;
	}

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public String getCms_num() {
        return cms_num;
    }

    public void setCms_num(String cms_num) {
        this.cms_num = cms_num;
    }

    public String getReid() {
        return reid;
    }

    public void setReid(String reid) {
        this.reid = reid;
    }

    public String getContentStyle() {
        return contentStyle;
    }

    public void setContentStyle(String contentStyle) {
        this.contentStyle = contentStyle;
    }

    public ArrayList<HomeMetaData> getList() {
		return list;
	}

	public void setList(ArrayList<HomeMetaData> list) {
		this.list = list;
	}

    public RedirectData getRedirectData() {
        return redirectData;
    }

    public void setRedirectData(RedirectData redirectData) {
        this.redirectData = redirectData;
    }
    
	public boolean ismHasStatistics() {
        return mHasStatistics;
    }

    public void setHasStatistics(boolean hasStatistics) {
        this.mHasStatistics = hasStatistics;
    }

    @Override
	public String toString() {
		return "blockname="+blockname+"cid="+cid+"area"+area+"bucket="+bucket+"cms_num="+cms_num+
				"redirectData="+redirectData+"contentStyle="+contentStyle+"list="+list;
	}
    
    
}
